package com.xinzhi.savingpot.rminfo.service.impl;

import com.xinzhi.savingpot.rminfo.entity.Recordinfo;
import com.xinzhi.savingpot.rminfo.mapper.ILimitAllMapper;
import com.xinzhi.savingpot.rminfo.pojo.LimitinfoVo;
import com.xinzhi.savingpot.rminfo.service.ILimitAllService;
import com.xinzhi.savingpot.util.BaseResponse;
import com.xinzhi.savingpot.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class LimitAllImpl implements ILimitAllService {
    @Autowired
    ILimitAllMapper iLimitAllMapper;
    @Autowired
    RedisUtil redisUtil;

    @Override
    public BaseResponse findLimitAll(int userid) {
        LimitinfoVo lv = new LimitinfoVo();
        List<Recordinfo> limitAll = iLimitAllMapper.getLimitAll(userid);
        if (!limitAll.isEmpty()){
            for (Recordinfo re: limitAll) {
                if (re.getFklimitrecordid().getLimittheway()==null){
                    return new BaseResponse(300, "暂无数据", null);
                }
                lv.setFilmtime(re.getFilmtime());
                lv.setLimitthat(re.getFklimitrecordid().getLimitthat());
                lv.setLimittheway(re.getFklimitrecordid().getLimittheway());
            }
            return new BaseResponse(200, "查询成功", lv);
            }
        return new BaseResponse(400, "暂无违规数据", null);
    }
}
